package reflect;

import reflect.annotation.AutoRunClass;
import reflect.annotation.AutoRunMethod;

import java.lang.reflect.Method;

public class ReflectDemo10 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");

        Object obj = cls.newInstance();
//        boolean mark = cls.isAnnotationPresent(AutoRunClass.class);
//        if (mark){
//            System.out.println("被标注了");
//        }else {
//            System.out.println("没有被标注");
//        }

        Method[] methods = cls.getMethods();
        for (Method method : methods) {
            boolean mark1 = method.isAnnotationPresent(AutoRunMethod.class);
            if (mark1){
                method.invoke(obj);
//                System.out.println(method.getName() + "被标注了");
            }
//            else {
//                System.out.println(method.getName() + "没有被标注");
//            }
        }
    }
}
